<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{

    protected $commands = [
        //
        'App\Console\Commands\WechatPushMedia',
        'App\Console\Commands\WechatKeywordMedia',
        'App\Console\Commands\WechatPush',
        'App\Console\Commands\WechatDepartment',
        'App\Console\Commands\WechatDepAccount',
        'App\Console\Commands\WechatCustomerData',
        'App\Console\Commands\WechatChatData',
        'App\Console\Commands\WechatAccountCustomer',
        'App\Console\Commands\WechatAccountChat',
        'App\Console\Commands\WechatCustomerRemark',
        'App\Console\Commands\WechatCorpAccount',
        'App\Console\Commands\WechatCheckinRecord',
        'App\Console\Commands\WechatTimingPushMedia',
        'App\Console\Commands\WechatTimingPush',
    ];

    /**
     * Define the application's command schedule.
     *
     * @param \Illuminate\Console\Scheduling\Schedule $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')->hourly();

        // 企微推送临时素材过期处理
        $schedule->command('push:media')->hourly()->runInBackground();

        // 企微定时推送临时素材过期处理
        $schedule->command('push:timing_media')->hourly()->runInBackground();

        // 企微关键字临时素材过期处理
        $schedule->command('keyword:media')->hourly()->runInBackground();

        // 同步企业部门/成员信息
        $schedule->command('wechat:department')->dailyAt('02:17');
        $schedule->command('wechat:dep_account')->dailyAt('03:17');

        // $schedule->command('wechat:corp_account')->everyTenMinutes()->runInBackground();

        // 统计成员客户数据
        $schedule->command('wechat:customer_data')->dailyAt('02:43');
        // 统计成员客户群数据
        $schedule->command('wechat:chat_data')->dailyAt('02:53');

        $schedule->command('wechat:account_customer')->hourlyAt(27);
        $schedule->command('wechat:account_chat')->hourlyAt(37);


        // 修改客户备注
        // $schedule->command('wechat:customer_remark')->everyMinute()->runInBackground()->withoutOverlapping();

        // 打卡
        // $schedule->command('wechat:checkin_record 1')->dailyAt('10:00')->runInBackground();
        // $schedule->command('wechat:checkin_record 2')->dailyAt('19:00')->runInBackground();

        // 企业微信推送
        $schedule->command('wechat:push 15')->everyFiveMinutes()->runInBackground()->withoutOverlapping();
        $schedule->command('wechat:push 30')->everyFiveMinutes()->runInBackground()->withoutOverlapping();
        $schedule->command('wechat:push 90')->everyFiveMinutes()->runInBackground()->withoutOverlapping();
        $schedule->command('wechat:push 240')->everyFiveMinutes()->runInBackground()->withoutOverlapping();
        $schedule->command('wechat:push 480')->everyFiveMinutes()->runInBackground()->withoutOverlapping();

        // 定时推送
        $schedule->command('wechat:timing_push')->hourly()->runInBackground()->withoutOverlapping();
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__ . '/Commands');

        require base_path('routes/console.php');
    }
}
